package com.ymttest.database.mongo;

import java.util.ArrayList;
import java.util.Map;

import org.json.JSONArray;

import com.ymt.database.MongoDBDriver;
import com.ymttest.business.service.AssertService;
import com.ymttest.utils.YMTDateUtil;

/************************************************************************************
 * @File name :SellerPromotionInfoWapper.java
 * @Author : 赵培培
 * @Date : 2016年10月31日
 * @Copyright : 洋码头
 * 满减促销库
 ************************************************************************************/
public class SellerPromotionInfoWapper {
	
	MongoDBDriver mdd = YmtMongoDriverFactroy.getInstance_SellerPromotionDBdriverNew("SellerPromotionInfo");
	

	/*
	 * 根据促销ID查询促销信息
	 */
	public Map<String,Object> getPromotionId(int PromotionId) throws Exception {
		
		ArrayList<Map> list = mdd.selectPartLimitToMap("{\"PromotionId\":" + PromotionId + "}",1);
	    
	    return list.size()>0?list.get(0):null;
	}
	/*
	 * 获取买手所有的促销信息
	 */
	
	public ArrayList<Map> getPromotions(int SellerId) throws Exception {
		
		ArrayList<Map> list = mdd.selectPartLimitToMap("{\"SellerId\":"+SellerId+"}",50);
	    return list;
	}
	
	
	public ArrayList<Map> getPromotions(Map<String, Object> searchMap) throws Exception {
		
		ArrayList<Map> list = mdd.selectPartLimitToMap(searchMap,10);
	    return list;
	}
	
	
	public static void main(String[] args) throws Exception {
		
		ArrayList<Map> a= new SellerPromotionInfoWapper().getPromotions(20323743);
		
		System.out.println(a.get(0).get("SellerId"));
		
			
			YMTDateUtil.waitTime(120);
		
	}   

}
